package com.tinygray.lock;

import java.util.Objects;
import java.util.concurrent.CountDownLatch;

/**
 * @Author: tinygray
 * @Description: 公众号:Madison龙少，关注我你会越来越优秀。
 * @className: CountDownLatchDemo
 * @create: 2021-05-08 19:05
 */
public class CountDownLatchDemo {
    private static final int count = 6;
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 1; i <= 6; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "\t 国灭了。。。");
                countDownLatch.countDown();
            }, Objects.requireNonNull(CountDownEnum.ForEach_CountDownEnum(i)).getRetMsg()).start();
        }
        //在countDownLatch等于0的时候才能执行主线程

        countDownLatch.await();
        System.out.println(Thread.currentThread().getName()+"\t 秦国灭了。。。。。。。。");
    }

}
